package ru.jexp.rcp.supply.beans.zs;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;

import ru.jexp.rcp.supply.beans.ek.ElementKomplektaciiViewer;
import ru.jexp.rcp.supply.beans.zs.wizard.NewWizardPage;
import ru.jexp.rcp.supply.beans.zs.wizard.WizardPageChooseEkPresenter;

public class WizardPageChooseEk extends NewWizardPage implements WizardPageChooseEkPresenter.IView
{
	private CheckboxTreeViewer viewer;
	private MenuManager contextMenu = new MenuManager();

	public WizardPageChooseEk(String pageName)
	{
		super(pageName);
		setTitle(pageName);
	}

	@Override
	public CheckboxTreeViewer getViewer()
	{
		return viewer;
	}

	@Override
	public void addContextMenuAction(IAction action)
	{
		contextMenu.add(action);
	}

	@Override
	protected void createWizardPage(Composite parent)
	{
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new FillLayout());

		createViewer(composite);

		setControl(composite);

		setPageComplete(true);
	}

	private void createViewer(Composite composite)
	{
		viewer = new ElementKomplektaciiViewer(composite);
		viewer.getTree().setMenu(contextMenu.createContextMenu(viewer.getTree()));
	}

}
